package com.panda.pandawash.activity;

import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.panda.pandawash.R;
import com.panda.pandawash.view.StatusBarCompat;

import org.xutils.view.annotation.Event;
import org.xutils.view.annotation.ViewInject;
import org.xutils.x;


public class AboutActivity extends AppCompatActivity {

	private final String pandaUrl = "<a href='http://www.simcotech.net'>http://www.simcotech.net</a>";

	@ViewInject(R.id.about_url)
	private TextView aboutUrl;

	@ViewInject(R.id.about_version)
	private TextView aboutVersion;

	@ViewInject(R.id.btn_about_return)
	private ImageView ic_return;


	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_about);
		x.view().inject(this);
		if(Build.VERSION.SDK_INT>= Build.VERSION_CODES.KITKAT) {
			StatusBarCompat.compat(this, getResources().getColor(R.color.colorPrimary));
		}
		CharSequence charSequence = Html.fromHtml(pandaUrl);
		aboutUrl.setText(charSequence);
		aboutUrl.setMovementMethod(LinkMovementMethod.getInstance());
		aboutVersion.setText(getVersion());

	}


	public String getVersion() {
		try {
			PackageManager manager = this.getPackageManager();
			PackageInfo info = manager.getPackageInfo(this.getPackageName(), 0);
			String version = info.versionName;
			return version;

		} catch (Exception e) {
			e.printStackTrace();
			return this.getString(R.string.can_not_find_version_name);
		}
	}

	@Event(R.id.btn_about_return)
	private void excuteReturn(View v) {
		finish();
	}

}
